import { EntitySchema } from '@mikro-orm/core';

export class ImsYzdKpCourseOrder {
  id!: number;
  uniacid!: number;
  userId!: number;
  ordercode!: string;
  outTradeNo!: string;
  totalPrice!: string;
  totalPayPrice!: string;
  sRemark?: unknown;
  submitTime!: string;
  isPay: boolean = false;
  payType: number = 0;
  payTime?: string;
  isSale: boolean = false;
  cancelState: boolean = false;
  cancelTime?: string;
  saleState: boolean = false;
  refundResult: boolean = false;
  refundState: boolean = false;
  refundContent?: unknown;
  refundImg?: unknown;
  autoCancelTime?: string;
  autoSalesTime!: string;
  distributePrice?: string;
  surplusPrice?: string;
  integral?: number;
  isForm?: boolean = false;
  courseId!: number;
  courseData!: unknown;
  courseType!: number;
  type?: number = 1;
  termTime?: string;
  beforeTime?: string;
  deviceType?: number;
  baidu?: unknown;
  payData?: unknown;
}

export const ImsYzdKpCourseOrderSchema = new EntitySchema({
  class: ImsYzdKpCourseOrder,
  properties: {
    id: { primary: true, type: 'number' },
    uniacid: { type: 'number', index: 'uniacid' },
    userId: { type: 'number', index: 'user_id' },
    ordercode: { type: 'string', length: 255 },
    outTradeNo: { type: 'string', length: 255 },
    totalPrice: { type: 'string', columnType: 'numeric(10,2)' },
    totalPayPrice: { type: 'string', columnType: 'numeric(10,2)' },
    sRemark: { type: 'unknown', columnType: 'longtext', nullable: true },
    submitTime: { type: 'string', length: 255 },
    isPay: { type: 'boolean', default: false },
    payType: { type: 'number', default: 0, index: 'pay_type' },
    payTime: { type: 'string', length: 255, nullable: true },
    isSale: { type: 'boolean', default: false, index: 'is_sale' },
    cancelState: { type: 'boolean', default: false, index: 'cancel_state' },
    cancelTime: { type: 'string', length: 255, nullable: true },
    saleState: { type: 'boolean', default: false, index: 'sale_state' },
    refundResult: { type: 'boolean', default: false, index: 'refund_result' },
    refundState: { type: 'boolean', default: false, index: 'refund_state' },
    refundContent: { type: 'unknown', columnType: 'longtext', nullable: true },
    refundImg: { type: 'unknown', columnType: 'longtext', nullable: true },
    autoCancelTime: { type: 'string', length: 255, nullable: true, default: '0' },
    autoSalesTime: { type: 'string', length: 255, default: '0' },
    distributePrice: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    surplusPrice: { type: 'string', columnType: 'numeric(10,2)', nullable: true },
    integral: { type: 'number', nullable: true },
    isForm: { type: 'boolean', nullable: true, default: false, index: 'is_form' },
    courseId: { type: 'number', index: 'course_id' },
    courseData: { type: 'unknown', columnType: 'longtext' },
    courseType: { type: 'number', index: 'course_type' },
    type: { type: 'number', nullable: true, default: 1, index: 'type' },
    termTime: { type: 'string', length: 255, nullable: true },
    beforeTime: { type: 'string', length: 255, nullable: true },
    deviceType: { type: 'number', fieldName: 'deviceType', nullable: true, index: 'deviceType' },
    baidu: { type: 'unknown', columnType: 'longtext', nullable: true },
    payData: {
      type: 'unknown',
      fieldName: 'payData',
      columnType: 'longtext',
      nullable: true,
    },
  },
});
